DIR_BIN = .
DIR_OBJ = ./build
DIR_SRC = ./src
TARGET = test

# CC=arm-linux-gnueabihf-g++
CC=g++
CXX_FLAG = -g -std=c++11#-Wall -O3
LINK_OPTION=-lpthread 
INC = -I ./inc
#全部文件
SRC = $(wildcard $(DIR_SRC)/*.cpp)
#指定文件
# SRC =./src/main.cpp \
# 	 ./src/tcp_client.cpp \
# 	 ./src/uart.cpp\
# 	 ./src/config.cpp\
# 	 ./src/app.cpp\
# 	 ./src/filesend.cpp

OBJ = $(patsubst %.cpp,$(DIR_OBJ)/%.o,$(notdir $(SRC)))

$(DIR_BIN)/$(TARGET) : $(OBJ) 
	$(CC) $(CXX_FLAG) -o $@ $^ $(LINK_OPTION)
	@echo -e "\033[32m cmompile [done]: $(TARGET)  \r\n\033[0m"
$(DIR_OBJ)/%.o : $(DIR_SRC)/%.cpp
	@if [ ! -d $(DIR_OBJ) ];	then mkdir -p $(DIR_OBJ); fi;
	$(CC) $(CXX_FLAG) $(INC) -o $@ -c $<

.PHONY : clean
clean : 
	@-rm -rf $(DIR_OBJ) $(TARGET)
	@echo -e "\033[33m clean done\033[0m"